package com.springboot.tools.listener;


import jakarta.servlet.*;
import jakarta.servlet.http.HttpSessionAttributeListener;
import jakarta.servlet.http.HttpSessionBindingEvent;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;

public class FirstListener implements ServletContextListener, HttpSessionListener, ServletRequestListener, ServletContextAttributeListener, HttpSessionAttributeListener, ServletRequestAttributeListener {

    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
        System.out.println("-FirstListener-----contextDestroyed-");
    }

    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        String param = arg0.getServletContext().getInitParameter("initParam");
        System.out.println("-FirstListener-----contextInitialized-param" + param);
    }

    @Override
    public void sessionCreated(HttpSessionEvent arg0) {
        System.out.println("-FirstListener-----sessionCreated-");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent arg0) {
        System.out.println("-FirstListener-----sessionDestroyed-");

    }

    @Override
    public void requestDestroyed(ServletRequestEvent arg0) {
        System.out.println("-FirstListener-----requestDestroyed-");
    }

    @Override
    public void requestInitialized(ServletRequestEvent arg0) {
        String name = arg0.getServletRequest().getParameter("name");
        System.out.println("-FirstListener-----requestInitialized-name===" + name);
    }

    @Override
    public void attributeAdded(ServletRequestAttributeEvent arg0) {
        System.out.println("-FirstListener--ServletRequestAttribute---attributeAdded-" + arg0.getName());

    }

    @Override
    public void attributeRemoved(ServletRequestAttributeEvent arg0) {
        System.out.println("-FirstListener--ServletRequestAttribute---attributeRemoved-" + arg0.getName());


    }

    @Override
    public void attributeReplaced(ServletRequestAttributeEvent arg0) {
        System.out.println("-FirstListener--ServletRequestAttribute---attributeReplaced-" + arg0.getName());


    }

    @Override
    public void attributeAdded(ServletContextAttributeEvent arg0) {
        System.out.println("-FirstListener-ServletContextAttribute---attributeAdded-" + arg0.getName());

    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent arg0) {
        System.out.println("-FirstListener-ServletContextAttribute---attributeRemoved-" + arg0.getName());

    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent arg0) {
        System.out.println("-FirstListener-ServletContextAttribute---attributeReplaced-" + arg0.getName());

    }

}
